home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 001-100 / 001-025 / 014 / amiga3d / objectallocate.c < prev    next >
C/C++ Source or Header  |  1995-03-17  |  2KB  |  102 lines

  1. #include <exec/types.h>
  2. #include <exec/memory.h>
  3. #include "threed.h"
  4.  
  5.  
  6. allocateobjectinfolist(view,screen,window,firstobjectinfo,firstobject)
  7. struct View *view;
  8. struct Screen *screen;
  9. struct Window *window;
  10. struct Objectinfo **firstobjectinfo;
  11. struct Object *firstobject;
  12. {
  13.     struct Object *ob;
  14.     int error = FALSE;
  15.  
  16.     /* allocate objectinfo structures */
  17.  
  18.     /* for all the objects in this objectsegment */
  19.  
  20.     for (ob = firstobject; ob; ob = ob->nextobject)
  21.     {
  22.         struct Objectinfo *thisobjectinfo;
  23.  
  24. #ifdef CAMERADEBUG
  25.         printf("test3d: allocate objectinfo for object(%lx) ",ob);
  26. #endif
  27.  
  28.         /* allocate an objectinfo structure for the current object */
  29.  
  30.         if ((thisobjectinfo = (struct Objectinfo *)AllocMem(sizeof(struct Objectinfo),MEMF_PUBLIC|MEMF_CLEAR)) == NULL) 
  31.         {
  32.         error = TRUE;
  33.         return(error); 
  34.         }
  35.  
  36. #ifdef CAMERADEBUG
  37.         printf("= %lx\n",thisobjectinfo);
  38. #endif
  39.         /* initialize the buffers for the current 3d object */
  40.  
  41.         if(!objectinit(view,screen,window,thisobjectinfo,ob))
  42.         {
  43.         error = TRUE;
  44.             return(error);
  45.         }
  46.  
  47.         /* make this objectinfo last on the objectinfo list */
  48.         {
  49.         struct Objectinfo **oipp;
  50.  
  51.         oipp =  firstobjectinfo;
  52.         while (*oipp)
  53.         {
  54.             oipp = &((*oipp)->nextobjectinfo);
  55.         }
  56.         *oipp = thisobjectinfo;
  57.          thisobjectinfo->nextobjectinfo = NULL;
  58.         }
  59.  
  60.     }
  61.  
  62. }
  63.  
  64.  
  65. deallocateobjectinfolist(view,screen,window,firstobjectinfo)
  66. struct View *view;
  67. struct Screen *screen;
  68. struct Window *window;
  69. struct Objectinfo **firstobjectinfo;
  70. {
  71.  
  72.     /* deallocate objectinfo structures */
  73.  
  74. #ifdef ODEBUG
  75.     printf("test3d: deallocate the active objectinfo structures...\n");
  76. #endif
  77.  
  78.     while( (*firstobjectinfo) )
  79.     {
  80.     struct Objectinfo *oip;
  81.  
  82.     /* delink the first objectinfo from the objectinfo list */
  83.  
  84.     oip = *firstobjectinfo;
  85.  
  86.     (*firstobjectinfo) = (*firstobjectinfo)->nextobjectinfo;
  87.  
  88.     /* deallocate the buffers dependent on the current objectinfo */
  89.  
  90. #ifdef ODEBUG
  91.     printf("    deallocate objectinfo(%lx)\n",oip);
  92. #endif
  93.  
  94.     objectdeallocate(view,screen,window,oip);
  95.  
  96.     /* deallocate this objectinfo structure itself */
  97.  
  98.     FreeMem(oip,sizeof(struct Objectinfo));
  99.     }
  100.  
  101. }
  102.